import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/login',
    method: 'post',
    data
  })
}

export function getUsers(query) {
  return request({
    url: '/list',
    method: 'get',
    params: query
  })
}

export function handleUser(data) {
  return request({
    url: '/handle',
    method: 'post',
    data
  })
}

export function fetchUser(id) {
  return request({
    url: `/detail/${id}`,
    method: 'put'
  })
}

export function deleteUser(id) {
  return request({
    url: `/delete/${id}`,
    method: 'delete'
  })
}

export function getInfo(token) {
  return request({
    url: '/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/logout',
    method: 'post'
  })
}

export function captcha() {
  return request({
    url: '/captcha',
    method: 'get'
  })
}

export function handlePassword(data) {
  return request({
    url: '/handle/password',
    method: 'post',
    data
  })
}

export function getLastServerList(query) {
  return request({
    url: '/dashboard/server/last/list',
    method: 'get',
    params: query
  })
}

export function getOverviewList(query) {
  return request({
    url: '/dashboard/overview/list',
    method: 'get',
    params: query
  })
}

export function getLogLoginList(query) {
  return request({
    url: '/dashboard/log/login',
    method: 'get',
    params: query
  })
}

export function getLogOftenLoginList(query) {
  return request({
    url: '/dashboard/log/often/login',
    method: 'get',
    params: query
  })
}

// 首页饼图数据
export function getPieData(query) {
  return request({
    url: '/dashboard/pie/data',
    method: 'get',
    params: query
  })
}

// 首页今日充值排行
export function getTodayRechargeRank(query) {
  return request({
    url: '/dashboard/today/recharge/rank',
    method: 'get',
    params: query
  })
}

// 首页监控记录
export function getMonitorLog(query) {
  return request({
    url: '/dashboard/monitor/log',
    method: 'get',
    params: query
  })
}
